package org.xg.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xg.assistant.SmallZhiAgent;
import org.xg.bean.ChatForm;
import reactor.core.publisher.Flux;

/**
 * @author hans
 * @date 2025/05/09 18:18
 * @description 小智智能体接收前端的用户请求
 */
@Tag(name = "小智智能体")
@RestController
@RequestMapping("/smallZhi")
public class SmallZhiController {

    @Autowired
    private SmallZhiAgent smallZhiAgent;


//    @Operation(summary = "小智智能体--聊天")
//    @PostMapping("/chat")
//    public String chat(@RequestBody ChatForm chatForm) {
//        return smallZhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
//    }

    @Operation(summary = "小智智能体--聊天--流式输出")
    @PostMapping(value = "/chat", produces = "text/stream;charset=UTF-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        return smallZhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }
}
